package net.imwork.lee9213.helper;

import net.imwork.lee9213.ConfigConstant;
import net.imwork.lee9213.util.PropertiesUtil;

import java.util.Properties;

/**
 * 属性文件助手类
 *
 * @author lee9213@163.com
 * @version 1.0
 * @date 2017/3/16 8:10
 */
public final class ConfigHelper {

    private static final Properties CONFIG_PROPS = PropertiesUtil.loadProperties(ConfigConstant.CONFIG_FILE);

    /**
     * 获取JDBC驱动
     *
     * @return
     */
    public static String getJdbcDriver() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.JDBC_DRIVER);
    }

    /**
     * 获取JDBC URL
     *
     * @return
     */
    public static String getJdbuUrl() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.JDBC_URL);
    }

    /**
     * 获取JDBC用户名
     *
     * @return
     */
    public static String getJdbcUsername() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.JDBC_USERNAME);
    }

    /**
     * 获取JDBC密码
     *
     * @return
     */
    public static String getJdbcPassword() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.JDBC_PASSWORD);
    }

    /**
     * 获取应用基础包名
     *
     * @return
     */
    public static String getAppBasePackage() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.APP_BASE_PACKAGE);
    }

    /**
     * 获取应用JSP路径
     *
     * @return
     */
    public static String getAppJspPath() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.APP_JSP_PATH, "WEB-INF/view/");
    }

    /**
     * 获取应用静态资源路径
     *
     * @return
     */
    public static String getAppAssetPath() {
        return PropertiesUtil.getString(CONFIG_PROPS, ConfigConstant.APP_ASSET_PATH, "/asset/");
    }

    /**
     * 获取应用上传限制
     *
     * @return
     */
    public static int getAppUploadLimit() {
        return PropertiesUtil.getInt(CONFIG_PROPS, ConfigConstant.APP_UPLOAD_LIMIT, 10);
    }
}
